/**
 * 页面公用类
 *
 * @author likunrui2
 * */
import {getHttpPath} from './my-utils'

// import {showMessage} from './my-plugin'
export const getIndicator = (_this, val) => {
  _this.$axios({
    method: 'get',
    url: '/api/anime/indicator?page=' + val
  })
    .then((res) => {
      if (res.data.code === 200) {
        _this.indicator.items = []
        let id = 0
        for (let item of res.data.data) {
          const a = {id: 0, isActive: false, cover: '/static/img/slide3.85b50ac.png', title: '出包王女', href: '#'}
          a.id = id
          a.cover = getHttpPath(item.cover)
          a.title = item.title
          a.href = item.href
          _this.indicator.items.push(a)
          id++
        }
        _this.indicator.items[0].isActive = true
      } else {
        console.log(res.data.msg)
      }
    })
    .catch((error) => {
      console.log(error)
    })
}

export const publicAcgInit = (_this, acg, val) => {
  acg.name = val.name
  acg.cover = getHttpPath(val.cover)
  acg.score = val.score
  acg.count = val.count
  acg.startTime = new Date(val.startTime)
  const infoArr = val.info.split('\n')
  let infoStr = ''
  for (let a of infoArr) {
    infoStr = infoStr + '<p>' + a + '</p>\n'
  }
  acg.info = infoStr
  acg.tag = val.tag
  acg.status = val.status
  // return acg
}
